package com.blitscreen.render 
{
	import flash.display.BitmapData;	
	
	import com.blitscreen.render.BasicDrawPass;
	
	/**
	 * @author Cédric Néhémie
	 */
	public class SortedDrawPass extends BasicDrawPass 
	{
		static private function NULL_SORT ( a : *, b : * ) : Number { return 0; }
		
		public var sortFunction : Function;
		
		public function SortedDrawPass ( mergeAlpha : Boolean = false, sortFunction : Function = null )
		{
			super( mergeAlpha );
			this.sortFunction = sortFunction != null ? sortFunction : NULL_SORT;
		}

		override public function render ( screen : BitmapData ) : void
		{
			_aSprites.sort( sortFunction );
			super.render( screen );
		}
	}
}
